home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Sprite 1984 - 1993
/
Sprite 1984 - 1993.iso
/
src
/
lib
/
c
/
mig
/
RCS
/
Mig_GetInfo.c,v
< prev
next >
Wrap
Text File
|
1990-06-22
|
6KB
|
278 lines
head 2.1;
branch ;
access ;
symbols no-auto-remigrate:2.1 installed:2.0;
locks ; strict;
comment @ * @;
2.1
date 90.06.22.14.58.23; author douglis; state Exp;
branches ;
next 2.0;
2.0
date 90.03.10.13.12.50; author douglis; state Stable;
branches ;
next 1.3;
1.3
date 90.03.10.13.11.16; author douglis; state Exp;
branches ;
next 1.2;
1.2
date 90.02.28.10.58.07; author douglis; state Exp;
branches ;
next 1.1;
1.1
date 90.02.16.14.29.24; author douglis; state Exp;
branches ;
next ;
desc
@Source code for the Mig_GetInfo procedure, which gets migration
and load information for a particular host. Note: if getting
local information, the "state" of the machine is not guaranteed to
be accurate; this variant is provided just for getting updated load
averages periodically.
@
2.1
log
@changes for alarms for timeouts with migd and for printing to stderr instead of syslog
@
text
@/*
* Mig_GetInfo.c --
*
* Source code for the Mig_GetInfo procedure, which gets migration
* and load information for a particular host. Note: if getting
* local information, the "state" of the machine is not guaranteed to
* be accurate; this variant is provided just for getting updated load
* averages periodically.
*
* Copyright 1990 Regents of the University of California
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
* fee is hereby granted, provided that the above copyright
* notice appear in all copies. The University of California
* makes no representations about the suitability of this
* software for any purpose. It is provided "as is" without
* express or implied warranty.
*/
#ifndef lint
static char rcsid[] = "$Header: /sprite/src/lib/c/mig/RCS/Mig_GetInfo.c,v 2.0 90/03/10 13:12:50 douglis Stable Locker: douglis $ SPRITE (Berkeley)";
#endif not lint
#include <sprite.h>
#include <stdio.h>
#include <mig.h>
#include <kernel/net.h>
#include <errno.h>
extern int errno;
extern char *strerror();
extern char *malloc();
/*
*----------------------------------------------------------------------
*
* Mig_GetInfo --
*
* Get the record for the given host (PROC_MY_HOSTID implies the current
* host).
*
* Results:
* A pointer to a static area (valid until the next call to Mig_GetInfo)
* is returned if the call is successful. On error, NULL is returned.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
#define INFO_BUF_SIZE (2 * sizeof(int) + sizeof(Mig_Info))
Mig_Info *
Mig_GetInfo(hostID)
int hostID;
{
int status;
Mig_InfoRequest request;
static Mig_Info info; /* Migration data, returned to user. */
static char *buffer = NULL;
int retry = 1;
if (hostID == PROC_MY_HOSTID) {
if (mig_LocalPdev < 0) {
if (MigOpenPdev(FALSE) < 0) {
return((Mig_Info *) NULL);
}
}
while (retry >= 0) {
status = read(mig_LocalPdev, (char *) &info, sizeof(Mig_Info));
if (status != sizeof(Mig_Info)) {
close(mig_LocalPdev);
mig_LocalPdev = -1;
if (retry == 0 || MigOpenPdev(FALSE) < 0) {
fprintf(stderr,
"Mig_GetInfo: error reading load from migd: %s\n",
strerror(errno));
return((Mig_Info *) NULL);
}
retry--;
} else {
break;
}
}
} else {
if (mig_GlobalPdev < 0) {
if (MigOpenPdev(TRUE) < 0) {
return((Mig_Info *) NULL);
}
}
if (buffer == (char *) NULL) {
buffer = malloc(INFO_BUF_SIZE);
if (buffer == (char *) NULL) {
/*
* Out of memory?!
*/
return((Mig_Info *) NULL);
}
}
request.numRecs = 1;
request.firstHost = hostID;
while (retry >= 0) {
if (MigSetAlarm() < 0) {
fprintf(stderr,
"Error setting alarm for contact with migd.\n");
return((Mig_Info *) NULL);
}
status = Fs_IOControl(mig_GlobalPdev, IOC_MIG_GETINFO,
sizeof(Mig_InfoRequest),
(char *) &request,
INFO_BUF_SIZE, (char *) buffer);
if (MigClearAlarm() < 0) {
fprintf(stderr,
"Error clearing alarm for contact with migd.\n");
}
if (status != SUCCESS) {
close(mig_GlobalPdev);
mig_GlobalPdev = -1;
if (retry == 0 || MigOpenPdev(TRUE) < 0) {
fprintf(stderr,
"Mig_GetInfo: error during ioctl to global master: %s\n",
Stat_GetMsg(status));
errno = Compat_MapCode(status);
return((Mig_Info *) NULL);
}
retry--;
} else {
break;
}
}
if (*((int *) buffer) != 1) {
fprintf(stderr,
"Mig_GetInfo: Got %d hosts during ioctl to global master.\n",
*((int *) buffer));
return((Mig_Info *) NULL);
}
bcopy(buffer + 2 * sizeof(int), (char *) &info,
sizeof(Mig_Info));
}
return(&info);
}
@
2.0
log
@Changing version numbers.
@
text
@d21 1
a21 1
static char rcsid[] = "$Header: /sprite/src/lib/c/mig/RCS/Mig_GetInfo.c,v 1.3 90/03/10 13:11:16 douglis Exp Locker: douglis $ SPRITE (Berkeley)";
d25 1
a26 1
#include <syslog.h>
d76 1
a76 1
syslog(LOG_WARNING,
d104 5
d113 4
d121 1
a121 1
syslog(LOG_WARNING,
d133 1
a133 1
syslog(LOG_WARNING,
@
1.3
log
@changed when it prints syslog message
@
text
@d21 1
a21 1
static char rcsid[] = "$Header: /sprite/src/lib/c/mig/RCS/Mig_GetInfo.c,v 1.2 90/02/28 10:58:07 douglis Exp Locker: douglis $ SPRITE (Berkeley)";
@
1.2
log
@changed Mig_OpenPdev to internal Mig routine. retry after read of local
pdev fails.
@
text
@d21 1
a21 1
static char rcsid[] = "$Header: /sprite/src/lib/c/mig/RCS/Mig_GetInfo.c,v 1.1 90/02/16 14:29:24 douglis Exp Locker: douglis $ SPRITE (Berkeley)";
a72 3
syslog(LOG_WARNING,
"Mig_GetInfo: error reading load from migd: %s\n",
strerror(status));
d76 3
a78 1
errno = Compat_MapCode(status);
a108 3
syslog(LOG_WARNING,
"Mig_GetInfo: error during ioctl to global master: %s\n",
Stat_GetMsg(status));
d112 3
@
1.1
log
@Initial revision
@
text
@d21 1
a21 1
static char rcsid[] = "$Header: /user2/douglis/pdev_mig/mig_p/RCS/Mig_GetInfo.c,v 1.2 90/02/13 10:07:12 douglis Exp Locker: douglis $ SPRITE (Berkeley)";
d66 1
a66 1
if (Mig_OpenPdev(FALSE) < 0) {
d70 16
a85 3
status = read(mig_LocalPdev, (char *) &info, sizeof(Mig_Info));
if (status != sizeof(Mig_Info)) {
return((Mig_Info *) NULL);
d89 1
a89 1
if (Mig_OpenPdev(TRUE) < 0) {
d115 1
a115 1
if (retry == 0 || Mig_OpenPdev(TRUE) < 0) {
@